package GameLogic;

import java.lang.Math;
import java.util.List;

public abstract class Entity {
    double timeExisted;
    public int entityId;
    public boolean isEnemy;
	public int health;
	protected EntityModel model;
	public double spawnOffset;
	public boolean onscreen;
	public boolean isProjectile;
    public double distance;
    public int value;
	
    public EntityCoordinate eCoord;
    
    public void tick()
    {
    	distance = Math.pow(eCoord.posX, 2)+Math.pow(eCoord.posY, 2);
		timeExisted+=0.0041f;
    }
    
    Entity()
    {
    	eCoord = new EntityCoordinate();
    }
    
	public void subtractHealth(int attackStrength)
	{
		health-=attackStrength;
	}
    
    Entity(double initPosX, double initPosY)
    {
    	eCoord = new EntityCoordinate(initPosX, initPosY, 0, 0, 1, 1, entityId);
    }
    
    public void setpos(double x, double y)
    {
    	eCoord.posX = x;
    	eCoord.posY = y;
    }
    
    protected void updatePositionArray(double posX, double posY) //called every time updateMovementByPath() to update position.
    {
    		eCoord.posX = posX;
    		eCoord.posY = posY;
    }
    
    public boolean equals(Entity e)
    {
    	return (e.entityId == entityId);
    }
    
	protected boolean isInRadiusOf(Entity target, float collisionRadius)
	{
		double distance;
		distance = Math.pow((eCoord.posX - target.eCoord.posX), 2.0f) + Math.pow((eCoord.posY-target.eCoord.posY), 2.0f);
		//pow is faster than sqrt, so just square the radius.
		return (distance<Math.pow(collisionRadius, 2));
	}
	
	public EntityCoordinate getCoordinates()
	{
		return eCoord;
	}
	
	void destroy()
	{
		//play kill animation, remove the object
	}

    abstract void updateMovementByPath();
    
    public EntityModel getModelType(){
    	return model;
    }
}
